<?php
/**
 * 军队需要缴纳税金
 * 征税者访问军队，并向每个找到的单位征税，不同的单位的税率不同
 * Class TaxCollectionVisitor
 */
class TaxCollectionVisitor extends ArmyVisitor{
	private $due = 0;
	private $report = "";

	function visit( $node){
		$this->levy($node,1);
	}

	function visitArcher(Archer $node){
		$this->levy($node,2);
	}

	function visitCavalry(Cavalry $node){
		$this->levy($node,3);
	}

	function visitLaserCanonUnit(LaserCanonUnit $node){
		$this->levy($node,4);
	}

	function visitTroopCarrier(TroopCarrier $node){
		$this->levy($node,5);
	}

	private function levy( $unit,$amount){
		$this->report .= "Tax levied for".get_class($unit);
		$this->report .= ": $amount\n<BR>";
		$this->due += $amount;
	}
	

	function getReport(){
		return $this->report;
	}

	function getTax(){
		return $this->due;
	}
}